/*
 * @lc app=leetcode.cn id=819 lang=javascript
 *
 * [819] 最常见的单词
 */

// @lc code=start
/**
 * @param {string} paragraph
 * @param {string[]} banned
 * @return {string}
 */
var mostCommonWord = function (paragraph, banned) {
    let map = new Map()
    let longWord = ""
    let word = ""
    let count = 0
    arr = paragraph.match(/[a-zA-Z]+/g)
    arr.forEach((item) => {
        let temp=item.toLowerCase()
        if (map.has(temp)) {
            map.set(temp, map.get(temp) + 1)
        } else {
            map.set(temp, 1)
        }
    })
    map.forEach((v, k) => {
        if (v > count && !banned.includes(k)) { longWord = k; count = v }
    })
    return longWord
};
// @lc code=end

